package com.nuc.thread.reentrantlock;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author 诗酒趁年华
 * @version 1.0.0
 * @Description 测试ReentrantLock的可重入性
 * @createTime 2021年07月10日 10:40:00
 */
@Slf4j
public class Test1 {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        lock.lock();
        try{
            log.debug("进入main方法");
            m1();
        }finally {
            lock.unlock();
        }
    }

    static void m1(){
        lock.lock();
        try{
            log.debug("进入m1方法");
            m2();
        }finally {
            lock.unlock();
        }
    }
    static void m2(){
        lock.lock();
        try{
            log.debug("进入m2方法");
        }finally {
            lock.unlock();
        }
    }

}
